// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
import  VueResource  from 'vue-resource';
import store from './vuex/store.js'

import $ from 'jquery';
window.jQuery = $;
window.$ = $;

router.beforeEach(function (to, from, next) {//路由守卫
  store.commit('updateLoadingStatus', {isLoading: true})
  setTimeout(() => {
    next()
  }, 200)
})
router.afterEach(function (to) {
  store.commit('updateLoadingStatus', {isLoading: false})
})

import VueSocketIO from 'vue-socket.io';
Vue.use(new VueSocketIO({
  debug: true,
  connection: 'http://localhost:3001',
  vuex: {
      store,
      actionPrefix: 'SOCKET_',
      mutationPrefix: 'SOCKET_'
  }
}))

import  { ToastPlugin } from 'vux'
Vue.use(ToastPlugin)

import  { LoadingPlugin } from 'vux'
Vue.use(LoadingPlugin)

import  { ConfirmPlugin } from 'vux'
Vue.use(ConfirmPlugin)

import { XInput,XButton,Group,Cell,XHeader,Tabbar,TabbarItem,Previewer,Flexbox,FlexboxItem,Divider,TransferDom,Grid, GridItem,Tab,TabItem,Sticky,Loading,Icon,WechatEmotion,Popup,XSwitch  } from 'vux'
import { XTextarea,LoadMore,XDialog,Flow,FlowState,FlowLine,Radio,Badge} from 'vux'
Vue.component('x-input', XInput)
Vue.component('x-button', XButton)
Vue.component('x-switch', XSwitch)
Vue.component('group', Group)
Vue.component('cell', Cell)
Vue.component('x-header', XHeader)
Vue.component('tabbar', Tabbar)
Vue.component('tabbar-item', TabbarItem)
Vue.component('previewer', Previewer)
Vue.component('flexbox', Flexbox)
Vue.component('flexbox-item', FlexboxItem)
Vue.component('divider', Divider)
Vue.directive('transfer-dom', TransferDom)
Vue.component('grid', Grid)
Vue.component('grid-item', GridItem)
Vue.component('tab', Tab)
Vue.component('tab-item', TabItem)
Vue.component('sticky', Sticky)
Vue.component('loading', Loading)
Vue.component('icon', Icon)
Vue.component('wechat-emotion', WechatEmotion)
Vue.component('popup', Popup)
Vue.component('x-textarea', XTextarea)
Vue.component('load-more', LoadMore)
Vue.component('load-more', LoadMore)
Vue.component('x-dialog', XDialog)
Vue.component('flow', Flow)
Vue.component('flow-state', FlowState)
Vue.component('flow-line', FlowLine)
Vue.component('radio', Radio)
Vue.component('badge', Badge)

import {Upload,Dialog,Button,Input} from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
Vue.use(Upload);
Vue.use(Dialog);
Vue.use(Button);
Vue.use(Input);

import preview from 'vue-photo-preview'
import 'vue-photo-preview/dist/skin.css'
Vue.use(preview)


Vue.use(VueResource);
Vue.config.productionTip = false

/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  store,
  render: h => h(App)
})
